﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 图解算法数据结构._50_ReverseLeftWords
{
    class MainProject
    {
        static void Main(string[] args)
        {
            Console.WriteLine(ReverseLeftWords("abc", 1));
            Console.ReadKey();
        }
        public static string ReverseLeftWords(string s, int n)
        {
            return s.Substring(n, s.Length - n) + s.Substring(0, n);

            #region 自定义方法
            string subS = s.Substring(0, n);

            char[] chars = s.ToArray();

            for (int i = 0; i < chars.Length; i++)
            {
                if (i + n< chars.Length)
                {
                    chars[i] = chars[i + n];
                }
            }
            int j = 0;
            for (int i = chars.Length-n; i < chars.Length; i++)
            {
                if (j< subS.Length)
                {
                    chars[i] = subS[j];
                    j++;
                }
            }
            return new string(chars);
            #endregion
        }
    }
}
